<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div v-if="!isLogin">
        <a href="javascript:void(0)" @click="login()">注册</a>
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>
    <div v-if="isLogin">
        <input type="text" v-model="info">
        <a href="javascript:void(0)" @click="add()">添加</a>
        <a href="javascript:void(0)" @click="logOut()">登出</a>
    </div>
    <ul>
        <li v-for="name in names">{{name}}</li>
    </ul>
</div>

<!--引入Vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            isLogin:false,
            info:"",
            names:["刘备","关羽"]
        },
        methods:{
            login:function () {
                v.isLogin = true;
            },
            add:function () {
                v.names.push(v.info)
            },
            logOut:function () {
                v.isLogin = false;
            }
        }
    })

</script>
</body>
</html>